package tr.mesir.view;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 * This is the base class for backing-beans. Aim is to group the common functionality here, 
 * like faces messaging and such.
 * 
 * @author mertcaliskan
 *
 */
public abstract class PageCodeBase {

	String getRequestVal(String key) {
		return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(key);
	}
	
	void addFacesMessageInfo(String msg) {
		FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
		FacesContext.getCurrentInstance().addMessage(null, facesMessage);
	}
	
	void addFacesMessageError(String msg) {
		FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg);
		FacesContext.getCurrentInstance().addMessage(null, facesMessage);
	}
}